import 'dart:convert';

import '../config/dioConfig.dart';
import '../enum/token.dart';
import '../tools/commons.dart';


refreshToken() async {
  var res = await HttpManager.getInstance().get(
      "/auth/refresh/",
      // 添加请求头
      headers: {
        "token":await CommonUtils.getToken(Token.RefreshToken),
        "__isRefresh":true
      },
  );
  Map resData =json.decode(res.toString())["data"];
  //判断长度
  return resData.isNotEmpty && resData.containsKey(Token.RefreshToken.toString()) && resData.containsKey(Token.AccessToken.toString());
}

Future<bool> isRefreshRequest (config) async {
  return config.headers.containsKey("__isRefresh")
      && config.headers["__isRefresh"];
}